/**
 * Created by no1 on 2015/10/29.
 */
'use strict';
var F = require('../../function');
var C = require('../../../config');
var redisCo = F.redisCo;
function DaoBase(data) {
  this.data = data;
}

DaoBase.prototype.save = function* (key, value) {
  let ret = yield redisCo.set(key, value);
  yield redisCo.expire(key, C.redisPre.user_ttl);
  return F.returnData(0, 'ok', ret);
};
DaoBase.prototype.saveByHmset = function* (tabName, obj) {
  if (typeof tabName === 'undefined') return F.returnData(1, '必须有tabName');
  if (typeof obj !== 'object') return F.returnData(1, '第二个参数必须为对象类型');
  let ret = yield redisCo.hmset(tabName, obj);
  //let ret2 = yield redisCo.hmget(tabName,'a','b');
  return F.returnData(0, 'ok', ret);
};

DaoBase.prototype.find = function* (key) {
  let ret = yield redisCo.get(key);
  return F.returnData(0, 'ok', ret);
};

DaoBase.prototype.update = function* (key, value) {
  return F.returnData(0, 'ok');
};
module.exports = DaoBase;